package servlet.article;

import dao.ArticleDao;
import entity.Article;
import util.GetParamToClass;
import util.R;
import util.ResposeUtil;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class DetailServlet extends HttpServlet {
    ArticleDao articleDao = new ArticleDao();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Article article = (Article) GetParamToClass.setObjectFiled(req,Article.class);
        Article one = articleDao.getOne(article.getId());
        ResposeUtil.write(new R(R.CODE_SUCCESS, one) ,resp);
    }
}
